package com.chen.Dome6TCP3;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class ServerReader extends Thread {
    private Socket s;

    public ServerReader(Socket s) {// 构造方法// 把参数保存起来
        this.s = s;
    }

    @Override
    public void run() {
        try {
            //给当前的浏览器网页相应一个网页数据
            OutputStream os = s.getOutputStream();
            //向浏览器输出数据
            PrintStream ps = new PrintStream(os);
            ps.println("HTTP/1.1 200 OK");
            ps.println("Content-Type:text/html;charset=utf-8");
            ps.println();//空行
            ps.println("<html>");
            ps.println("<body>");
            ps.println("<h1>我爱你宝贝，希望你天天开心</h1>");
            ps.println("<img src='C:\\图片1.png'>");
            System.out.println("<img src='C:\\图片1.png'>");
            ps.println("</body>");
            ps.println("</html>");
            ps.close();
            s.close();
            } catch(Exception e){
            System.out.println(s.getInetAddress().getHostAddress()+"客户下线了");
            }

        }
    }

